<?php

namespace app\api\controller;

use app\BaseController;
use think\facade\Db;

class Message extends BaseController
{
    /**
     * 添加队伍
     * @return [type] [description]
     */
    public function list()
    {
        $list = Db::name('mesg')->where('uid',$this->request->users['id'])->paginate(10)->toArray();

        foreach ($list['data'] as $key => $value) {
            $list['data'][$key]['create_time'] = date('Y-m-d H:i:s',$value['create_time']);

            if ($value['type'] == 1) {
            	$list['data'][$key]['name'] = Db::name('team')->where('id',$value['id'])->value('name');
            }
        }

        if ($list) {
            return json(['code'=>1,'data'=>$list]);
        } else {
            return json(['code'=>0,'info'=>'获取失败']);
        }
    }
}